package com.example.demo.Controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ControllerTest {
    @RequestMapping("/hello")
    @ResponseBody
    public String Xiaotao(@RequestParam(name = "name") String name){
        return "Hello" + name;
    }
    @RequestMapping("/student")
    @ResponseBody
    public String student(Students students){
        return students.toString();
    }
    @ModelAttribute
    public void parseUsers(@RequestParam(name = "name", defaultValue = "unknown users") String name,
                           @RequestParam(name = "id", defaultValue = "6") Integer id, Students users){
        users.setName(name);
        users.setId(id);
    }
    @RequestMapping("/html")
    public String page(){
        return "page.html";
    }
}
